<script>
$(document).ready(function() {
	<?php
	if ($error == 'file_type') echo 'showNoti("Hỗ trợ .png .jpg .gif", "Định dạng image không hợp lệ!", "Err");';
	if ($updated == 1) echo 'showNoti("Sản phẩm: '.$name.'", "Cập nhập sản phẩm thành công!", "Ok");';
	if ($failed == 1) echo 'showNoti("Sản phẩm: '.$name.'", "Cập nhập sản phẩm thất bại!", "Err");';
    $articles_added = str_replace(array('[',']','"'), array(''), $info['articles']);
	?>
    list_product(0, $.cookie('cat'), $('#q').val(), '<?php echo $this->input->cookie('proids', true) ?>');
    $('.cat_treeview input').change(function() {
        list_product(0, $(this).val(), '', '<?php echo $this->input->cookie('proids', true) ?>');
        $.cookie('cat', $(this).val());
    });
    $('.btn.btn-info').bind('click', function(event) {
        list_product(0, $.cookie('cat'), $('#q').val(), '<?php echo $this->input->cookie('proids', true) ?>');
    });
    list_article(0, $.cookie('cat2'), $('#q').val(), '<?php echo $this->input->cookie('newsids', true) ?>', '<?php echo $articles_added ?>');
    $('.cat_treeview2 input').change(function() {
        list_article(0, $(this).val(), '', '<?php echo $this->input->cookie('newsids', true) ?>', '<?php echo $articles_added ?>');
        $.cookie('cat2', $(this).val());
    });
    $('.btn.btn-info.btn2').bind('click', function(event) {
        list_article(0, $.cookie('cat2'), $('#q').val(), '<?php echo $this->input->cookie('newsids', true) ?>', '<?php echo $articles_added ?>');
    });
});
</script>
<script src="js/tinymce/tinymce.min.js"></script>
<script src="js/tinymce.js"></script>
<?php
echo form_open_multipart($action, array('id' => 'updateFrm'));
echo form_input(array('type' => 'hidden', 'name' => 'token', 'value' => $GLOBALS['var']['token']));
echo form_input(array('type' => 'hidden', 'name' => 'id', 'value' => $info['id']));
echo module_open();
?>
<tr class="no-border">
	<td>
        <input type="hidden" class="tabId" value="<?php echo $GLOBALS['var']['mytab'] ?>" />
        <ul id="myTab" class="nav nav-tabs">
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 0 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-0" data-toggle="tab">Thông tin</a></li>
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 1 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-1" data-toggle="tab">Giá &amp; Giới thiệu</a></li>
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 3 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-3" data-toggle="tab">Hình ảnh</a></li>
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 4 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-4" data-toggle="tab">Thiết lập</a></li>
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 7 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-7" data-toggle="tab">Seo tags</a></li>
            <li class="dropdown active show640">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="current-tab-name">Thông tin</span> <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li <?php echo ($GLOBALS['var']['mytab'] == 0 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-0" data-toggle="tab">Thông tin</a></li>
                    <li <?php echo ($GLOBALS['var']['mytab'] == 1 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-1" data-toggle="tab">Giá &amp; Giới thiệu</a></li>
                    <li <?php echo ($GLOBALS['var']['mytab'] == 3 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-3" data-toggle="tab">Hình ảnh</a></li>
                    <li <?php echo ($GLOBALS['var']['mytab'] == 4 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-4" data-toggle="tab">Thiết lập</a></li>
                    <li <?php echo ($GLOBALS['var']['mytab'] == 7 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-7" data-toggle="tab">Seo tags</a></li>
                </ul>
            </li>
        </ul>
        <div id="myTabContent" class="tab-content">
            <div id="tabs-0" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 0 ? ' active' : '') ?>">
            	<table cellpadding="0" cellspacing="0" width="100%" border="0">
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Tên sản phẩm<?php if ($GLOBALS['cfg']['multi_lang']) { ?> tiếng VIệt<?php } ?> <span style="color:red">*</span></div>
                            <div class="tdright clr320">
                                <input type="text" data-required="1" name="name_vn" id="name_vn" value="<?php echo $info['name_vn'] ?>" style="width:300px;" />
                                <div class="errordiv name_vn"><div class="arrow"></div>Vui lòng nhập tên sản phẩm!</div>
                            </div>
                        </td>
                    </tr>
                    <?php
                    if ($GLOBALS['cfg']['multi_lang'])
                    {
                    ?>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Tên sản phẩm tiếng Anh</div>
                            <div class="tdleft clr320"><input type="text" name="name_en" id="name_en" value="<?php echo $info['name_en'] ?>" style="width:300px;" /></div>
                        </td>
                    </tr>
                    <?php
                    }
                    ?>
                    <tr>
                        <td class="fr">
                            <div class="tdleft">Mã sản phẩm <span style="color:red">*</span></div>
                            <div class="tdright">
                                <input type="text" data-required="1" name="code" id="code" value="<?php echo $info['code'] ?>" style="width: 210px; font-size: 21px;" maxlength="15" />
                                <input type="hidden" data-required="1" name="" value="1" id="errCode">
                                <div class="errordiv errCode"><div class="arrow"></div>Vui lòng nhập mã sản phẩm khách!</div>
                                <div class="errordiv code"><div class="arrow"></div>Vui lòng nhập mã sản phẩm!</div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Danh mục <span style="color:red">*</span></div>
                            <div class="tdright clr320">
                                <ul class="cat_treeview filetree treeview" style="height: 350px !important; width: 250px;"><?php echo cat_tree($category_list, 0, $info['cat'], 'radio'); ?></ul>
                                <div class="note" style="margin-top: 5px;">Lưu ý: Sản phẩm chỉ hiển thị ở những danh mục nào được chọn.</div>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="tabs-1" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 1 ? ' active' : '') ?>">
            	<table cellpadding="0" cellspacing="0" width="100%" border="0">
                	<tr>
                        <td class="fr">
                            <div class="tdleft">Giá nhập <span style="color:red">*</span></div>
                            <div class="tdright">
                                <input type="text" name="gia1" data-required="1" id="gia1" class="money" value="<?php echo number_format($info['gia1']) ?>" style="width:70px !important; text-align: right;" /> đ
                                <div class="errordiv gia1"><div class="arrow"></div>Vui lòng nhập giá mua!</div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft">Giá bán <span style="color:red">*</span></div>
                            <div class="tdright">
                                <input type="text" name="gia2" data-required="1" id="gia2" class="money" value="<?php echo number_format($info['gia2']) ?>" style="width:70px !important; text-align: right;" /> đ
                                <div class="errordiv gia2"><div class="arrow"></div>Vui lòng nhập giá bán!</div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft">Giảm giá</div>
                            <div class="tdright"><input type="text" name="giam" id="giam" class="money" value="<?php echo number_format($info['giam']) ?>" style="width:70px !important; text-align: right;" /> %</div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Xuất xứ</div>
                            <div class="tdright clr320">
                                <ul class="css3-radios">
                                    <?php
                                    foreach ($xuatxu_list as $data)
                                    {
                                        echo '<li>';
                                        echo '<label style="float: left; margin-right: 10px">';
                                        echo '<input type="radio" name="xuatxu" value="'.$data['id'].'"'.($info['xuatxu'] == $data['id'] ? " checked='checked'" : "").' />';
                                        echo '<span>'.$data['name_vn'].'</span>';
                                        echo '</label>';
                                        echo '</li>';
                                    }
                                    ?>
                                </ul>
                            </div>
                        </td>
                    </tr>
                  
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Kích thước</div>
                            <div class="tdright clr320"><input type="text" name="kichthuoc" id="kichthuoc" value="<?php echo $info['kichthuoc'] ?>" style="width:150px;" /></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Kiểu</div>
                            <div class="tdright clr320"><input type="text" name="doituong" id="doituong" value="<?php echo $info['doituong'] ?>" style="width:150px;" /></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Điểm nổi bật<?php if ($GLOBALS['cfg']['multi_lang']) { ?> tiếng VIệt<?php } ?></div>
                            <div class="tdright clr320"><input type="text" name="des_vn" style="width:320px" value="<?php echo $info['des_vn']?>" /></div>
                        </td>
                    </tr>
                    <?php
                    if ($GLOBALS['cfg']['multi_lang'])
                    {
                    ?>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Điểm nổi bật tiếng Anh</div>
                            <div class="tdright clr320"><textarea name="des_en" style="width:100%; height:120px"><?php echo $info['des_en']?></textarea></div>
                        </td>
                    </tr>
                    <?php
                    }
                    ?>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Phạm vi sử dụng</div>
                            <div class="tdright clr320"><input type="text" name="congdung" style="width:320px" value="<?php echo $info['congdung']?>" /></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Bảo hành</div>
                            <div class="tdright clr320">
                                <ul class="css3-radios">
                                    <?php
                                    foreach ($bh_list as $data)
                                    {
                                        echo '<li>';
                                        echo '<label style="float: left; margin-right: 10px">';
                                        echo '<input type="radio" name="bh" value="'.$data['id'].'"'.($info['bh'] == $data['id'] ? " checked='checked'" : "").' />';
                                        echo '<span>'.$data['name_vn'].'</span>';
                                        echo '</label>';
                                        echo '</li>';
                                    }
                                    ?>
                                </ul>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="tabs-3" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 3 ? ' active' : '') ?>">
            	<table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td class="head">Ảnh nhỏ sản phẩm</td>
                    </tr>
                    <tr>
                        <td class="fr" valign="top" width="470px">
                            <div class="image-wrap">
                                <input class="selectImage" type="file" name="img" />
                                <div class="image">
                                    <div class="no-image">
                                        <i class="icon36 glyphicons picture" style="<?php if(goodfile(PRO.'thumbs/'.$info['img'])) { ?>display:none;<?php } ?>"></i>
                                        <img class="preview_img" title="Click để chọn ảnh" style="<?php if(!goodfile(PRO.'thumbs/'.$info['img'])) { ?>display:none;<?php } ?>" src="<?php echo PRO ?>thumbs/<?php echo $info['img']?>" />
                                        <?php if ($info['img']) echo del_image('img', $info['id']); ?>
                                    </div>
                                </div>
                                <div class="image-des">
                                    <h2>Ảnh đại diện</h2>
                                    <p>Hình thu nhỏ sẽ được tạo ra tự động từ hình ảnh đại diện</p>
                                    <div class="file-name">
                                        <div>
                                            <i class="icon glyphicons remove_2"></i> <p></p>
                                        </div>
                                    </div>
                                    <div class="input-group" style="width: 200px !important">
                                        <span class="input-group-addon" title="Alternative text/title"><i class="icon glyphicons chat"></i></span>
                                        <input type="text" name="img_alt" value="<?php echo $info['img_alt'] ?>" style="width: 250px;" class="" />
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="head">Upload hình ảnh bổ sung</td>
                    </tr>
                    <tr>
                        <td class="fr" valign="top">
                            <div style="position: relative; width: 97%">
                                <div id="fileuploader" data-dir="<?php echo PRO ?>" data-thumb-w="<?php echo $thumb_width ?>" data-thumb-h="<?php echo $thumb_height ?>" data-gallery-w="<?php echo $gallery_width ?>" data-gallery-h="<?php echo $gallery_height ?>">
                                    <i class="icon glyphicons white picture"></i> Chọn file
                                </div>
                                <div id="startUpload" class="submitBtn btn btn-success" style="position: absolute; top: 12px; right: 5px;"><i class="icon glyphicons white cloud_plus"></i> Upload</div>
                            </div>
                            <div style="clear: both;">&nbsp;</div>
                            <div id="images-list">
                                <?php
                                $imagelist = json_decode($info['images']);
                                if (!empty($imagelist))
                                {
                                    foreach ($imagelist as $data)
                                    {
                                        echo '<div class="image-wrap fl"><i class="icon glyphicons remove"></i><input data-file="'.$data.'" value="'.$data.'" type="hidden" name="images[]" /><div class="image-small"><div class="no-image"><img src="'.PRO.'thumbs/'.$data.'" /></div></div></div>';
                                    }
                                }
                                ?>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="tabs-4" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 4 ? ' active' : '') ?>">
            	<table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td class='fr'>
                            <div class="tdleft clr320">Tình trạng</div>
                            <div class="tdright clr320">
                                <ul class="css3-radios">
                                <?php
                                foreach ($tinhtrang_list as $data)
                                {
                                    echo '<li>';
                                    echo '<label for="tinhtrang'.$data['id'].'">';
                                    echo '<input type="radio" name="tinhtrang" id="tinhtrang'.$data['id'].'" value="'.$data['id'].'"'.($data['id'] == $info['tinhtrang'] ? ' checked="checked"' : '').' />';
                                    echo '<span>'.$data['name_vn'].'</span>';
                                    echo '</label>';
                                    echo '</li>';
                                }
                                ?>
                                </ul>
                            </div>
                        </td>
                    </tr>
                    <tr>
                    	<td class='fr'>
                            <div class="tdleft">Cho bình luận</div>
                            <div class="tdright">
                                <ul class="css3-radios">
                                    <li><label><input name='comment' type='radio' value='1'<?php echo($info['comment'] == '1' ? " checked=checked" : "") ?> /><span>Có</span></label></li>
                                    <li><label><input name='comment' type='radio' value='0'<?php echo($info['comment'] == '0' ? ' checked="checked"' : '') ?> /><span>Không</span></label></li>
                                </ul>
                            </div>
                        </td>
                	</tr>
                	<tr>
                    	<td class='fr'>
                            <div class="tdleft">Kích hoạt</div>
                            <div class="tdright">
                                <ul class="css3-radios">
                                    <li><label><input name='active' type='radio' value='1'<?php echo($info['active'] == 1 ? " checked=checked" : "") ?> /><span>Có</span></label></li>
                                    <li><label><input name='active' type='radio' value='0'<?php echo($info['active'] == '0' ? ' checked="checked"' : '') ?> /><span>Không</span></label></li>
                                </ul>
                            </div>
                        </td>
                	</tr>
                    <tr>
                    	<td class='fr'>
                            <div class="tdleft">Đánh dấu mới</div>
                            <div class="tdright">
                                <ul class="css3-radios">
                                    <li><label><input name='new' type='radio' value='1'<?php echo($info['new'] == 1 ? " checked=checked" : "") ?> /><span>Có</span></label></li>
                                    <li><label><input name='new' type='radio' value='0'<?php echo($info['new'] == '0' ? ' checked="checked"' : '') ?> /><span>Không</span></label></li>
                                </ul>
                            </div>
                        </td>
                	</tr>
                	<tr>
                    	<td class='fr'>
                            <div class="tdleft">Nổi bật</div>
                            <div class="tdright">
                                <ul class="css3-radios">
                                    <li><label><input name='hot' type='radio' value='1'<?php echo($info['hot'] == 1 ? " checked=checked" : "") ?> /><span>Có</span></label></li>
                                    <li><label><input name='hot' type='radio' value='0'<?php echo($info['hot'] == '0' ? ' checked="checked"' : '') ?> /><span>Không</span></label></li>
                                </ul>
                            </div>
                        </td>
                	</tr>
                    <tr>
                    	<td class="fr">
                            <div class="tdleft">Bán chạy</div>
                            <div class="tdright">
                                <ul class="css3-radios">
                                    <li><label><input name='best' type='radio' value='1'<?php echo($info['best'] == 1 ? " checked=checked" : "") ?> /><span>Có</span></label></li>
                                    <li><label><input name='best' type='radio' value='0'<?php echo($info['best'] == '0' ? ' checked="checked"' : '') ?> /><span>Không</span></label></li>
                                </ul>
                            </div>
                        </td>
                	</tr>
                </table>
            </div>
            <div id="tabs-7" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 7 ? ' active' : '') ?>">
            	<table cellpadding="0" cellspacing="0" width="100%" border="0">
                    <tr>
                        <td class="fr">
                            <div class="tdleft">Tạo sitemap</div>
                            <div class="tdright">
                                <ul class="css3-radios">
                                    <li><label><input name='sitemap' type='radio' value='1'<?php echo($info['sitemap'] == '1' ? " checked=checked" : "") ?> /><span>Có</span></label></li>
                                    <li><label><input name='sitemap' type='radio' value='0'<?php echo($info['sitemap'] == '0' ? " checked=checked" : "") ?> /><span>Không</span></label></li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">
                            <div class="tdleft clr320">Seo description</div>
                            <div class="tdright clr320"><textarea name="seo_desc" style="width:300px !important; height:80px"><?php echo $info['seo_desc']?></textarea><br /><span class="note">từ 0 đến 150 ký tự</span></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr" style="position: relative">
                            <div class="tdleft clr320">Seo keywords</div>
                            <div class="tdright clr320">
                                <input type="text" name="tags" id="tags" value="<?php echo $info['tags']?>" style="width:300px !important;" />
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
	</td>
</tr>
<?php echo module_close(); ?>